package com.shihb.akka.actors

import akka.actor.{ActorRef, ActorSystem, Props}

/**
 * Description:两个Actor相互通讯
 * AActor主动者
 * BActor消息接收者
 *
 * @author shihb
 * @date 2020/10/2 20:29
 */
object ActorGame {

  def main(args: Array[String]): Unit = {
    // 创建ActorSystem
    val actorFactory: ActorSystem = ActorSystem("actorFactory")
    // 先创建BActor的引用
    val bActor: ActorRef = actorFactory.actorOf(Props[BActor], "BActor")
    val aActor: ActorRef = actorFactory.actorOf(Props(new AActor(bActor)), "AActor")
    aActor!"start"
  }

}
